<template>
	<div>
		<div class="mainBox">
			<el-form :inline="true" :model="ruleForm" :rules="rules" ref="ruleForm" label-width="110px" class="formBox">
			<el-row :gutter="20">
				<el-col :span="8">
					<el-form-item label="会员账号" prop="user_count">
						<el-input placeholder="请输入会员账号" v-model="ruleForm.user_count"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="消费单号"  prop="consumption_number">
						<el-input placeholder="请输入消费单号" v-model="ruleForm.consumption_number"></el-input>
					</el-form-item>
               </el-col>
			   	<el-col :span="8">
					<el-form-item label="所属门店"  prop="subordinate_stores">
						<el-input placeholder="" v-model="ruleForm.subordinate_stores" :disabled="disable"></el-input>
					</el-form-item>
               </el-col>
			   	<el-col :span="8">
					<el-form-item label="消费金额"  prop="consumption_amount" >
						<el-input placeholder="请输入消费金额" v-model="ruleForm.consumption_amount" type="number"></el-input>
					</el-form-item>
               </el-col>
				<el-col :span="8">
				<el-form-item class="secondRow_formItem" style="margin-left:35px;">
						<el-button type="primary" @click="submitForm('ruleForm')" v-loading="submitLoading">确定</el-button>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		</div>
	</div>
</template>

<script>
import {integralEnterLogIn} from '@/api/user'
export default{
	data(){
		return{
			disable:true,
			submitLoading:false,
			ruleForm:{
				user_count:"",
				consumption_number:"",
				subordinate_stores:JSON.parse(this.$store.state.user.getStore).storeName,
				consumption_amount:""
			},
			rules:{
                   user_count: [{
							required: true,
							message: '请输入会员账号',
							trigger: 'blur'
						},
					],
					consumption_number: [{
							required: true,
							message: '请输入消费单号',
							trigger: 'blur'
						},
					],
					consumption_amount: [{
							required: true,
							message: '请输入消费金额',
							trigger: 'blur'
						},
					],
			}
		}
	},
	methods:{
		submitForm(formName) {
			
				this.$refs[formName].validate((valid) => {
					let data={
						memberId:this.ruleForm.user_count,
						consumptionNumber:this.ruleForm.consumption_number,
						consumptionMoney:this.ruleForm.consumption_amount
					}
					this.submitLoading=true
					if (valid) {
					integralEnterLogIn(data).then(res=>{
						if(res.code==200){
							this.$message.success("入账成功")
							this.submitLoading=false
							this.ruleForm.user_count=""
							this.ruleForm.consumption_number=""
							this.ruleForm.consumption_amount=""

						}else{
							this.$message.error(res.msg)
							this.submitLoading=false
						}
					})
					} else {
						this.submitLoading=false
						return false;
					}
				});
			}
	}
}
</script>

<style>
	.formBox {
		margin-top: 20px;
	}
</style>
